home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / tex / metafo~1 / mfsrc.lzh / COMMON.LZH / EXTRA.H < prev    next >
C/C++ Source or Header  |  1991-01-13  |  4KB  |  123 lines

  1. /* Main include file for this implementation.  Everybody includes this.  */
  2.  
  3. #ifndef EXTRA_H
  4. #define EXTRA_H
  5.  
  6. #include <stdio.h>
  7. #include "site.h"
  8. #include "../common/common.h"
  9.  
  10. /* Path searching.  The `...PATH' constants are used both as indices and
  11.    just as enumeration values.  Their values must match the
  12.    initialization of `env_var_names' in extra.c.  The `...PATHBIT'
  13.    constants are used in the argument to `setpaths'.  */
  14. #define BIBINPUTPATH    0
  15. #define BIBINPUTPATHBIT (1 << BIBINPUTPATH)
  16. #define GFFILEPATH    1
  17. #define GFFILEPATHBIT (1 << GFFILEPATH)
  18. #define MFBASEPATH    2
  19. #define MFBASEPATHBIT (1 << MFBASEPATH)
  20. #define MFINPUTPATH    3
  21. #define MFINPUTPATHBIT (1 << MFINPUTPATH)
  22. #define MFPOOLPATH    4
  23. #define MFPOOLPATHBIT (1 << MFPOOLPATH)
  24. #define PKFILEPATH    5
  25. #define PKFILEPATHBIT (1 << PKFILEPATH)
  26. #define TEXFORMATPATH    6
  27. #define TEXFORMATPATHBIT (1 << TEXFORMATPATH)
  28. #define TEXINPUTPATH    7
  29. #define TEXINPUTPATHBIT (1 << TEXINPUTPATH)
  30. #define TEXPOOLPATH    8
  31. #define TEXPOOLPATHBIT (1 << TEXPOOLPATH)
  32. #define TFMFILEPATH    9
  33. #define TFMFILEPATHBIT (1 << TFMFILEPATH)
  34. #define VFFILEPATH     10
  35. #define VFFILEPATHBIT (1 << VFFILEPATH)
  36.  
  37. /* Globally needed routines we can implement as macros.  */
  38.  
  39. /* Absolute value.  Without the casts to integer here, the Ultrix and
  40.    AIX compilers (at least) produce bad code (or maybe it's that I don't
  41.    understand all the casting rules in C) for tests on memory fields. 
  42.    Specifically, a test in diag_round (in Metafont) on a quarterword
  43.    comes out differently without the cast, thus causing the trap test to
  44.    fail.  (A path at line 86 is constructed slightly differently).  */
  45. #define    abs(x)        ((integer) (x) >= 0 ? (integer) (x) : (integer) -(x))
  46.  
  47. #define    chr(x)        (x)
  48. #define    decr(x)        --(x)
  49. #define eof(f)        test_eof (f)
  50. #define    fabs(x)        ((x) >= 0.0 ? (x) : -(x))
  51. #define flush(f)    (void) fflush (f)
  52. #define    Fputs(f, s)    (void) fputs (s, f)  /* fixwrites outputs this.  */
  53. #define    incr(x)        ++(x)
  54. #define    input3ints(a, b, c)  zinput3ints (&a, &b, &c)
  55. #define    odd(x)        ((x) % 2)
  56. #define ord(x)        (x)
  57. #define printreal(r, n, m)  fprintreal (stdout, r, n, m)
  58. #define    putbyte(x, f)    putc ((char) (x) & 255, f)
  59. #define read(f, b)    ((b) = getc (f))
  60. #define    readln(f)    { register c; \
  61.                           while ((c = getc (f)) != '\n' && c != EOF) \
  62.                 if (c == '\r' || c == 26) continue; }
  63. #define    round(x)    zround ((double) (x))
  64.  
  65. /* Open files for reading and writing.  */
  66. #define    reset(f, n) \
  67.   ((f) ? fclose (f) : 0), (f) = checked_fopen ((char *) (n), "r")
  68. #define rewrite(f, n) \
  69.   (f) = checked_fopen ((char *) (n), "w")
  70.  
  71. #define    toint(x)    ((integer) (x))
  72.  
  73. /* Pascal's predefined `trunc' routine.  */
  74. #define trunc(x)    ((integer) (x))
  75.  
  76. /* ``Unix exit'', since WEB already defines the symbol `exit'.  */
  77. #define    uexit        exit
  78.  
  79. /* For throwing away input from the file F.  */
  80. #define vgetc(f)    (void) getc (f)
  81.  
  82. /* If we don't care that strcpy(3) returns A.  */
  83. #define vstrcpy(a, b)    (void) strcpy (a, b)
  84.  
  85. /* Write out elements START through END of BUF to the file F.  */
  86. #define writechunk(f, buf, start, end) \
  87.   (void) fwrite (&buf[start], sizeof (buf[start]), end - start + 1, f)
  88.  
  89. /* Like fseek(3), but cast the arguments and ignore the return value.  */
  90. #define checkedfseek(f, n, w)  (void) fseek(f, (long) n, (int) w)
  91.  
  92.  
  93. /* C doesn't distinguish between text files and other files.  */
  94. typedef FILE *text, *file_ptr;
  95.  
  96. /* For some initializations of constant strings.  */
  97. typedef char *ccharpointer;
  98.  
  99. /* We need one global variable.  */
  100. extern integer argc;
  101.  
  102. /* Routines in extra.c and main.c.  */
  103. #ifdef ANSI
  104. extern void argv (int, char[]);
  105. extern FILE *checked_fopen (char *, char *);
  106. extern boolean eoln (FILE *);
  107. extern void fprintreal (FILE *, double, int, int);
  108. extern integer inputint (FILE *);
  109. extern char *xmalloc (unsigned), *xrealloc (char *, unsigned);
  110. extern integer zround (double);
  111. #else /* not ANSI */
  112. extern void argv ();
  113. extern FILE *checked_fopen ();
  114. extern boolean eoln ();
  115. extern void fprintreal ();
  116. extern integer inputint();
  117. extern void fprintreal ();
  118. extern char *xmalloc (), *xrealloc ();
  119. extern integer zround ();
  120. #endif /* not ANSI */
  121.  
  122. #endif /* not EXTRA_H */
  123.